<template>
  <view class="container">
    <view class="tab-box">
      <view :class="['tab', status == 0 ? 'active' : '']" @click="changeTab(0)">全部</view>
      <view :class="['tab', status == 1 ? 'active' : '']" @click="changeTab(1)">待审核</view>
      <view :class="['tab', status == 2 ? 'active' : '']" @click="changeTab(2)">已审核</view>
    </view>

    <scroll-view scroll-y @scrolltolower="loadMore" class="list">
      <view class="box" v-for="(item, index) in list" :key="index">
        <view :class="['status', item.status == 1 ? 'dsh' : (item.status == 2 ? 'ytg' : 'wtg')]">{{ item.status_desc }}</view>
        <view class="row">
          <view class="text">项目名称：</view>
          <view class="info">{{ item.project_name }}</view>
        </view>
        <view class="row">
          <view class="text">岗位：</view>
          <view class="info">{{ item.post_name }}</view>
        </view>
        <view class="row">
          <view class="text">学生信息：</view>
          <view class="info">{{ item.username }}、{{ item.mobile }}</view>
        </view>
        <view class="btn-box">
          <navigator v-if="item.status == 1" hover-class="none" :url="'/pages/join_status_detail/join_status_detail?id=' + item.id + '&index=' + index" class="btn">立即审核</navigator>
          <navigator v-if="item.status == 2" hover-class="none" :url="'/pages/join_status_detail/join_status_detail?id=' + item.id + '&index=' + index" class="btn">查看详情</navigator>
        </view>
      </view>

    </scroll-view>

  </view>
</template>

<script>
export default {
  data() {
    return {
      project_id: 0,
      status: 0,
      list: [],
      page: 1,
      pagesize: 10
    }
  },

  onLoad(options) {
    this.project_id = options.project_id;

    this.examinePostJoinList()
  },

  methods: {
    loadMore: function () {
      this.examinePostJoinList(this.page + 1)
    },

    changeTab: function (status) {
      this.page = 1;
      this.status = status;
      this.examinePostJoinList();
    },

    // 项目列表
    examinePostJoinList: function (incPage = 0) {
      var page = incPage ? incPage : this.page;

      uni.showLoading({
        title: '数据加载中...',
        mask: true
      })

      this.$http.post('/index/Api/examinePostJoinList', {
        project_id: this.project_id,
        status: this.status,
        page: page,
        pagesize: this.pagesize
      }).then((res) => {
        if (res.data.result == 1) {
          if (page == 1) {
            this.list = res.data.data;
          } else {
            // 加载更多
            var list = this.list;

            for (var i = 0; i < res.data.data.length; i++) {
              list.push(res.data.data[i]);
            }

            this.list = list;
            this.page = page;
          }

          setTimeout(() => {
            uni.hideLoading();
          }, 500)
        } else {
          if (page == 1) this.list = [];

          uni.hideLoading();
          this.$common.doErrorResult(res);
        }
      })
    },
  }
}
</script>

<style lang="scss">
.container {
  padding: 20rpx;
  background: #f5f5f5;

  .tab-box {
    display: flex;
    width: 70%;
    justify-content: space-between;
    margin-bottom: 20rpx;
    position: fixed;
    top: 20rpx;
    left: 20rpx;
    z-index: 99;

    .tab {
      text-align: center;
      flex: 1;
      color: #8C8888;
    }

    .active {
      color: #B574FF;
    }
  }

  .list {
    margin-top: 60rpx;
    height: calc(100vh - 120rpx);

    .box {
      display: flex;
      flex-direction: column;
      padding: 16rpx 24rpx;
      margin-bottom: 20rpx;
      background: #fff;
      border-radius: 20rpx;

      .status {
        text-align: right;
      }

      .dsh {
        color: #55B4FF;
      }

      .ytg {
        color: #B574FF;
      }

      .wtg {
        color: #FF7155;
      }

      .title {
        font-size: 32rpx;
        font-weight: bold;
      }

      .row {
        display: flex;
        align-items: center;
        margin-top: 14rpx;

        .text {
          font-size: 28rpx;
          width: 140rpx;
        }

        .info {
          font-size: 24rpx;
          color: #3D3D3D;
        }
      }

      .btn-box {
        display: flex;
        justify-content: flex-end;
        margin-top: 20rpx;

        .btn {
          font-size: 24rpx;
          color: #fff;
          background: #32a4ff;
          width: 120rpx;
          height: 60rpx;
          line-height: 60rpx;
          padding: 0 24rpx;
          border-radius: 50rpx;
          text-align: center;
          margin-left: 40rpx;
        }

      }

    }
  }

}

</style>
